﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Wicture.DbRESTFul;
using Wicture.QPZS.EPC.API.Domain.Entities;

namespace Wicture.QPZS.EPC.API.Throttlings
{
    public class AccountServicePackageRestThrotting : IThrottling
    {
        public decimal Order => 1;
        public List<ServicePackageType> ServicePackageTypes => new List<ServicePackageType> { ServicePackageType.包次 };

        public void Invoke(ThrottlingContext context)
        {
            var rest = context.AccountPackage.Rest;
            if (rest <= 0)
            {
                throw new LogicalException("账号余量不足。", 602);
            }
        }
    }
}
